<template>
    <srcoll-view class="video-main" @scrolltolower="handleTolower">
      <view class="video-item" v-for="item in videowp" :key="item.id" @click="handleGoVideo(item)">
        <image :src="item.img" mode="widthFix" />
      </view>
    </srcoll-view>
</template>

<script>
export default {
  props: {
    urlObj: Object
  },
  data(){
    return {
      videowp: [],
	  hasMore:true
    }
  },
  mounted () {
    this.getList();
  },
  watch: {
    urlObj(){
		this.videowp = []
      this.getList();
    }
  },
  methods: {
    getList(){
      this.request({
        url: this.urlObj.url,
        params: this.urlObj.params
      })
      .then(result=>{
		   
       if(result.res.videowp.length===0){
		  this.hasMore = false;
		  uni.showToast({
		  	title:"没有更多数据了",
		  	icon:"none"
		  });
		  return;
	   } 
	   this.videowp = [...this.videowp,...result.res.videowp];
      })
    },
	handleTolower(){
		if(this.hasMore){
			this.urlObj.params.skip+=this.urlObj.params.limit;
			this.getList()
		}else{
			uni.showToast({
				title:"没有更多数据了",
				icon:"none"
			})
		}
	},
		
	handleGoVideo(item){
		//console.log(item)
		getApp().globalData.video = item;
		
		uni.navigateTo({
			url:'../vieoPlay/vieoPlay'
		})
	}
  }
}
</script>

<style lang="scss">
.video-main {
  display: flex;
  flex-wrap: wrap;
  height: calc(100vh - 36px);
  .video-item {
    width: 33.33%;
    image {
      border: 5rpx solid #fff;
    }
  }
}
</style>